package com.amarsoft.task.security.login;

import com.amarsoft.task.Task;
import com.amarsoft.task.security.DefaultUser;
import com.amarsoft.task.security.LoginModule;
import com.amarsoft.task.security.TaskUser;
import java.util.Enumeration;

public class AnonymousLogin implements LoginModule {
	public TaskUser login(Task task) {
		DefaultUser du = new DefaultUser();
		du.setId(System.getProperty("user.name", "anonymous"));
		du.setName(du.getId());
		for (Enumeration<?> e = System.getProperties().keys(); e.hasMoreElements();) {
			String pn = (String) e.nextElement();
			if (pn.startsWith("user.")) {
				du.setProperty(pn.toUpperCase(), System.getProperty(pn));
			}
		}
		return du;
	}
}